<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Tuolaji <479923197@qq.com>
// +----------------------------------------------------------------------
namespace Publish\Controller;

use Common\Controller\HomebaseController;
class VideoController extends HomebaseController {

	protected $posts_model;
	protected $term_relationships_model;
	protected $terms_model;
	protected $history_model;
	protected $video_model;
	
	function _initialize() {
		parent::_initialize();
		$this->terms_model = D("Publish/SystemTerms");
		$this->person_model= D("Publish/PubPerson");
	// $this->posts_model = D("Publish/PubPosts");
	// $this->terms_model = D("Publish/SystemTerms");
	// $this->term_relationships_model = D("Publish/SystemTermRelationships");
	// $this->history_model=D("Publish/pub_history");
		$this->video_model=D("Publish/pub_video");

}

	// 视频列表
	public function index(){
		$id=I('term_id');
		$first_children=$this->terms_model->where("parent=$id")->select();
		// $video=$this->video_model->query("select new_pub_video.*,new_pub_person.id AS pid,new_pub_person.name from new_pub_video,new_pub_person where new_pub_video.person_id=new_pub_person.id and new_pub_person.name like '%$_POST[keyword]%'");
//		$video=$this->video_model->query("select new_pub_video.*,new_pub_person.id AS pid,new_pub_person.name from new_pub_video,new_pub_person where new_pub_video.person_id=new_pub_person.id and new_pub_person.name like '%$_POST[keyword]%'");
//		$video=$this->video_model->query("select new_pub_video.*,new_pub_person.id as pid,new_system_terms.term_id,new_system_term_relationships as re from new_pub_video,new_pub_person,new_system_terms where new_pub_video.person_id = pid and ");
		$video=$this->video_model
			->field("person_id,v_url")
			->alias("v")
			->join("__SYSTEM_TERM_RELATIONSHIPS__ str ON v.person_id=str.object_id")
			->join("__SYSTEM_TERMS__ st ON str.term_id=st.term_id")
			->where(array("parent"=>$id))
			->select();
//		echo "<pre>";
//		print_r($video);
		for($i=0;$i<count($video);$i++){
			$p_name=$this->person_model
				->field("name")
				->where(array("id"=>$video[$i]['person_id']))
				->find();
			$video[$i]['name']=$p_name['name'];
		}
		$this->assign('videoall',$video);
		// dump($video);
		$this->assign('first_children',$first_children);
		$this->display("video");

	}

}